package com.liao.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.liao.dao.ResourDao;
import com.liao.util.Result;

@RestController
public class ResourController {
	@Autowired
	private ResourDao resourDao;

	@RequestMapping("/getAllResout")
	@ResponseBody
	public Object getAllResout(@RequestParam Map<String, Object> map) {
		Integer page = Integer.parseInt(map.get("page").toString());
		Integer limit = Integer.parseInt(map.get("limit").toString());
		map.put("page", (page - 1) * limit);
		map.put("limit", limit);
		List<Map<String, Object>> resour = resourDao.getAllResour(map);
		int count = resourDao.getCount();
		Result res = new Result("0", "true", count, resour);
		return res;
	}

	@RequestMapping("/Resouradd")
	@ResponseBody
	public Object Resourinserts(@RequestParam Map<String, Object> map) {
		Result res = new Result("0", "true", resourDao.Resouradd(map), "添加成功");
		return res;

	}

	@RequestMapping("/Resourupdate")
	@ResponseBody
	public Object Resourupdate(@RequestParam Map<String, Object> map) {
		Result res = new Result("0", "true", resourDao.Resourupdate(map), "修改成功");
		return res;

	}

	@RequestMapping("/Resourdelete")
	@ResponseBody
	public Object Resourdelete(@RequestParam("rsid")Integer rsid) {
		Result res = new Result("0", "true", resourDao.Resourdelete(rsid), "删除成功");
		return res;

	}
}
